<?php

//use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//'middleware' => 'admin',
Route::group(['prefix' => 'backend', 'namespace' => 'Backend'], function ($router) {
    # 友链相关
    Route::get('links', 'LinkController@index');
    Route::post('link', 'LinkController@create');
    Route::put('link', 'LinkController@update');
    Route::patch('link/{id}/audit', 'LinkController@auditLink');
    Route::patch('link/{id}/enable', 'LinkController@enableLink');
    Route::delete('link/{id}', 'LinkController@delLink');

    # 项目类型管理
    Route::get('project-types', 'ProjectTypeController@index');
    Route::post('project-type', 'ProjectTypeController@create');
    Route::put('project-type', 'ProjectTypeController@update');
    Route::patch('project-type/{id}/enable', 'ProjectTypeController@changeEnable');
    Route::delete('project-type/{id}', 'ProjectTypeController@del');

    # 项目管理
    Route::get('projects', 'ProjectController@index');
    Route::post('project', 'ProjectController@create');
    Route::put('project', 'ProjectController@update');
    Route::delete('project/{id}', 'ProjectController@del');

    # 关于我
    Route::get('about-me', 'AboutMeController@index');
    Route::post('about-me', 'AboutMeController@edit');

    # 文章相关
    Route::get("articles/archive", "ArticlesController@getArchive");
    Route::get('articles', 'ArticlesController@index');
    Route::post('articles', 'ArticlesController@create');
    Route::put('articles', 'ArticlesController@update');
    Route::patch('articles/{id}/enable', 'ArticlesController@changeEnable');
    Route::delete("articles/{id}", "ArticlesController@del");

    # 标签列表
    Route::get('tag', 'TagController@index');

    # 用户管理
    Route::get('user', 'UserController@index');
    Route::patch('user/{id}/enable', 'UserController@changeEnable');

    # 评论管理
    Route::get('comments', 'CommentController@index');
    Route::patch('comment/{id}/enable', 'CommentController@changeEnable');
    Route::delete('comment/{id}', 'CommentController@del');

    # 后台首页
    Route::get("index", "IndexController@index");
});

// Authorization: Bearer eyJhbGciOiJIUzI1NiI...
Route::group(['prefix' => 'auth'], function ($router) {
    Route::post('login', 'AuthController@login');
    Route::post('logout', 'AuthController@logout');
    Route::post('refresh', 'AuthController@refresh');
    Route::post('reset', 'AuthController@resetPassword');
    Route::post('me', 'AuthController@me');
});

// 上传
Route::post('upload', 'UploadController@upload');
